package 初级算法;

public class 旋转数组 {
    public static void main(String[] args) {
        int[] is = new int[]{1,2,3,4,5,6,7};
        rotate(is,3);
        System.out.println(is);
        for (int i : is) {
            System.out.println(i);
        }
    }
    public static void rotate(int[] nums, int k) {
        int temp[] = new int[nums.length];
        for(int i=0;i<nums.length;i++){
            temp[i]=nums[i];
        }
        for(int i=0;i<nums.length;i++){
            nums[(i+k)%nums.length]=temp[i];
        }
    }
}

